package com.ruoyi.web.controller.substation;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SParameterDetailsRemarks;
import com.ruoyi.system.service.ISParameterDetailsRemarksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参数列备注Controller
 * 
 * @author ruoyi
 * @date 2023-07-10
 */
@Api(tags = "参数列备注管理")
@RestController
@RequestMapping("/substation/remarks")
public class SParameterDetailsRemarksController extends BaseController
{
    @Autowired
    private ISParameterDetailsRemarksService sParameterDetailsRemarksService;

    /**
     * 查询参数列备注列表
     */
    @ApiOperation("获取参数列备注列表")
    @PreAuthorize("@ss.hasPermi('substation:remarks:list')")
    @GetMapping("/list")
    public AjaxResult list(SParameterDetailsRemarks sParameterDetailsRemarks)
    {
        List<SParameterDetailsRemarks> list = sParameterDetailsRemarksService.getList(sParameterDetailsRemarks);
        return success(list);
    }

    /**
     * 导出参数列备注列表
     */
    @ApiOperation("导出参数列备注列表")
    @PreAuthorize("@ss.hasPermi('substation:remarks:export')")
    @Log(title = "参数列备注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SParameterDetailsRemarks sParameterDetailsRemarks)
    {
        List<SParameterDetailsRemarks> list = sParameterDetailsRemarksService.list(sParameterDetailsRemarks.queryWrapper());
        ExcelUtil<SParameterDetailsRemarks> util = new ExcelUtil<SParameterDetailsRemarks>(SParameterDetailsRemarks.class);
        util.exportExcel(response, list, "参数列备注数据");
    }

    /**
     * 获取参数列备注详细信息
     */
    @ApiOperation("获取参数列备注详细")
    @ApiImplicitParam(name = "id", value = "参数列备注ID", required = true, dataType = "String", paramType = "path")
    @PreAuthorize("@ss.hasPermi('substation:remarks:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sParameterDetailsRemarksService.getById(id));
    }

    /**
     * 新增参数列备注
     */
    @ApiOperation("新增参数列备注")
    @PreAuthorize("@ss.hasPermi('substation:remarks:add')")
    @Log(title = "参数列备注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SParameterDetailsRemarks sParameterDetailsRemarks)
    {
        sParameterDetailsRemarks.setCreateBy(SecurityUtils.getUserId().toString());
        sParameterDetailsRemarks.setCreateTime(new Date());
        sParameterDetailsRemarks.setUpdateBy(SecurityUtils.getUserId().toString());
        sParameterDetailsRemarks.setUpdateTime(new Date());
        return toAjax(sParameterDetailsRemarksService.save(sParameterDetailsRemarks));
    }

    /**
     * 修改参数列备注
     */
    @ApiOperation("更新参数列备注")
    @PreAuthorize("@ss.hasPermi('substation:remarks:edit')")
    @Log(title = "参数列备注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SParameterDetailsRemarks sParameterDetailsRemarks)
    {
        sParameterDetailsRemarks.setUpdateBy(SecurityUtils.getUserId().toString());
        sParameterDetailsRemarks.setUpdateTime(new Date());
        return toAjax(sParameterDetailsRemarksService.updateById(sParameterDetailsRemarks));
    }

    /**
     * 删除参数列备注
     */
    @ApiOperation("删除参数列备注")
    @ApiImplicitParam(name = "ids", value = "参数列备注ID集合", required = true, dataType = "String", paramType = "path")
    @PreAuthorize("@ss.hasPermi('substation:remarks:remove')")
    @Log(title = "参数列备注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<String> ids)
    {
        return toAjax(sParameterDetailsRemarksService.removeByIds(ids));
    }
}
